package com.tfy.liquor.controller;

import com.tfy.liquor.bean.Result;
import com.tfy.liquor.service.FreightRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/freightRegion")
public class FreightRegionController {
    @Autowired
    private FreightRegionService freightRegionService;

    // 获取全部省级地址
    @RequestMapping("/getProvinceFreightRegion")
    public Result getProvinceFreightRegion() {
        return new Result(freightRegionService.getProvinceFreightRegion()).ok();
    }

    // 根据上级编号获取下级地址信息
    @RequestMapping("/getFreightRegionByPid")
    public Result getFreightRegionByPid(Integer pid) {
        if (null == pid || pid < 0) {
            return new Result().bad_CodeIsNull();
        }
        return new Result(freightRegionService.getFreightRegionByPid(pid)).ok();
    }
}
